from sqlmodel import Field, SQLModel
from sqlalchemy import JSON
from datetime import datetime

class WikidataEntity(SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    qid: str | None = Field(index=True)
    data: dict = Field(default=[], sa_type=JSON, sa_column_kwargs={"comment": "wikidata entity"}) 
      
    # 添加时间戳字段
    created_at: datetime = Field(default_factory=datetime.utcnow)
    updated_at: datetime = Field(default_factory=datetime.utcnow, index=True)
    
    

class WikidataSparqlModel(SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    query_key: str = Field(index=True)
    query: str | None = Field()
    data: dict | None = Field(sa_type=JSON, sa_column_kwargs={"comment": "wikidata sparql entity"}) 
    
    # 添加时间戳字段
    created_at: datetime = Field(default_factory=datetime.utcnow)
    updated_at: datetime = Field(default_factory=datetime.utcnow, index=True)